const path = require('path')
const webpack = require('webpack')
const VueLoaderPlugin = require('vue-loader/lib/plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const StylelintPlugin = require('stylelint-webpack-plugin')
module.exports = {
    mode: 'none',
    entry: {
        app: './src/main.js'
    },
    output: {
        path: path.join(__dirname, 'dist'),
        filename: 'js/[name].js',
    },
    module: {
        rules: [{
            test: /\.js$/,
            exclude: /node_modules/,
            use: [
                'babel-loader'
            ]
        }, {
            test: /\.vue$/,
            use: [
                'vue-loader'
            ]
        }, {
            test: /\.(js|vue)$/,
            exclude: /node_modules/,
            use: [
                'eslint-loader'
            ],
            enforce: 'pre'
        }, {
            test: /\.less$/,
            use: [
                'style-loader',
                'css-loader',
                'postcss-loader',
                'less-loader'
            ]
        }, {
            test: /\.css$/,
            use: [
                'style-loader',
                'css-loader',
                'postcss-loader',
            ]
        }, {
            test: /\.(png|jpg|jpeg|git)$/,
            use: {
                loader: 'url-loader',
                options: {
                    limit: 10 * 1024,
                    esModule: false,
                }
            }
        }]
    },
    plugins: [
        new webpack.DefinePlugin({
            BASE_URL: '"./"'
        }),
        new HtmlWebpackPlugin({
            template: './public/index.html',
            title: 'vue-xt'
        }),
        new VueLoaderPlugin(),
        new StylelintPlugin({
            files: ['src/**.{vue,html,css,less}'],
            cache: false,
            emitError: true,
        }),
    ],
    resolve: {
        extensions: ['.js', '.json', '.vue']
    }
}